<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>编辑音乐分类</title>
	<meta name="renderer" content="webkit">	
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
	<meta name="apple-mobile-web-app-status-bar-style" content="black">	
	<meta name="apple-mobile-web-app-capable" content="yes">	
	<meta name="format-detection" content="telephone=no">	
	<link rel="stylesheet" type="text/css" href="{$_W['siteroot']}addons/hr_album/style/component/layui/css/layui.css" media="all">
	<style>
.layui-form-pane .layui-form-label {
    min-width: 200px;
}
.layui-form-pane .layui-input-block {
    margin-left: 200px;
}
.demoimg,#logoimg{
	width: 38px;height: 38px; margin-left: 10px;display:none;
}
.demoimg img,#logoimg img{width: 100%; border-radius: 5px;height: 100%;}
	</style>
</head>
<body>
<form class="layui-form layui-form-pane" style="padding:20px;" action="{php echo url('site/entry/skin', array('m' => 'hr_album','op' => 'edit'));}" method="post">
<input type="hidden" name="id" value="{$item['id']}">
<div class="layui-form-item">
    <label class="layui-form-label">模板排序：</label>
    <div class="layui-input-block">
      <input type="text" name="displayorder"  lay-verify="required" value="{$item['displayorder']}"  placeholder="数值越大越靠前" autocomplete="off" class="layui-input">
    </div>
  </div> 
  <div class="layui-form-item" pane>
    <label class="layui-form-label">热门推荐</label>
    <div class="layui-input-block">
      <input type="radio" name="ishot" value="0" title="否"  {if $item['ishot'] == 0} checked="checked" {/if}>
      <input type="radio" name="ishot" value="1" title="是"  {if $item['ishot'] == 1} checked="checked" {/if}>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">模板名称：</label>
    <div class="layui-input-block">
      <input type="text" name="skintitle"  lay-verify="required" value="{$item['skintitle']}"  placeholder="请输入名称，不要超过三个字符否则会造成样式错乱。" autocomplete="off" class="layui-input">
    </div>
  </div>    
  <div class="layui-form-item">
          <label class="layui-form-label">选择分类：</label>
          <div class="layui-input-block">
            <select name="cate">
               {loop $cate $items}
              	<option value="{$items['id']}" {if $items['id'] == $item['cid']} selected{/if}>{$items['title']}</option>	
               {/loop}
            </select>
          </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">音频链接</label>
    <div class="layui-input-block">
      <input id="bgmusic" style="width:50%;float:left" type="text" name="musicurl" value="{$item['music']}"  placeholder="选择上传的音频文件或直接输入URL地址，常用格式：mp3 " autocomplete="off" class="layui-input">      
      {if $item['music']}<button type="button" id="playmusic" class="layui-btn">播放</button>{/if}
      <button id="audiolink" type="button" style="float:left;margin-left:5px;margin-right:5px;" class="layui-btn layui-btn-normal">获取音乐外链</button>
    </div>
  </div>  
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="layui-form">立即提交</button>
      <input type="hidden" name="token" value="{$_W['token']}" />
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>     
    </div>
  </div>
</form>
<script type="text/javascript" src="{$_W['siteroot']}addons/hr_album/style/js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="{$_W['siteroot']}addons/hr_album/style/component/layui/layui.js"></script>
<script type="text/javascript">
{if $item['music']}
var e_music_player = new Audio;
$("#playmusic").on('click',function(){
	e_music_player.src  = '{$item['music']}';
    e_music_player.loop = 'loop';    	
    var text = $(this).text();
    if(text == '播放'){
    	$(this).text('停止');
    	e_music_player.play();
    }else{
    	$(this).text('播放');
        e_music_player.pause();
    }

});
{/if}
layui.use(['form','upload'],function(){
    var form = layui.form();
    layui.upload({
    	  url: '{$_W['siteroot']}web/index.php?c=site&a=entry&do=setaudio&m=hr_album',
    	  type:'audio',
    	  success: function(res){
    		  layer.msg('音乐上传成功'); 
    		  $("#bgmusic").val(res.src);         
    	    console.log(res); //上传成功返回值，必须为json格式
    	  }
    	});      
});
$("#audiolink").on('click',function(){
	layui.use('layer', function(){
		layer.open({
			  type: 2, 
			  title: '搜索音乐',
			  content: '{$_W['siteroot']}web/index.php?c=site&a=entry&do=seachmusic&m=hr_album',
			  area: ['600px', '600px'],
			});  
	});
});
</script>
</body>
</html>